package org.hackystat.devcathlon.configuration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.InputStream;

import org.hackystat.devcathlon.configuration.jaxb.DevcathlonConfiguration;
import org.junit.Test;

/**
 * Tests that the ConfigurationManager can read in the example configuration file.
 * @author Philip Johnson
 *
 */
public class TestConfigurationManager {
  
  /**
   * Read in the configuration.example.xml file and check a few fields.
   * @throws Exception If problems occur.
   */
  @Test
  public void testConfigurationFile () throws Exception {
    InputStream stream = getClass().getResourceAsStream("configuration.example.xml");
    DevcathlonConfiguration config = ConfigurationManager.getInstance().getConfiguration(stream);
    assertTrue("Testing config", config.getHackystat().getSensorbase().startsWith("http:"));
    assertEquals("Test events", 8, config.getEventConfigurations().getEventConfiguration().size());
  }
}
